A5_HTML_LIST_ADO Function

Syntax

HTML_List as C = a5_HTML_List_ADO(P ADO [,C default_value [,N maxRows [,L htmlEncode ]]])

Arguments

HTML_List

A formatted HTML option list.

ADO

A pointer variable containing values for:

Variable
Description
Type

"Access"

MdbFileName

Path and filename of the MDB file.

SQL

An SQL SELECT statement that defines the records and fields to return.

default_value

Optional. The default selection.

maxRows

Optional. Default = 0 (All rows returned).

htmlEncode

Optional. Default = .T. .T. = Format as HTML .F. = Do not format as HTML

Description

Queries an ADO Record Set to return an OPTION list for use in an HTML form.

Discussion

Optionally populate the ado.parameters array, then call the function.

put description here

Syntax for Microsoft SQL Server

Optionally populate the ado.parameters array, then call the function. HTML_List as C = A5_HTML_LIST_ADO( Data as P [, Default as C [, Rows as N ]] )

Argument
Description
HTML_List

A formatted HTML option list.

Data

A pointer variable containing values for:

Variable
Description
Type

"connectionstring"

Parameter_Query

.T.

Connection_String

The connection string required to open the database.

SQL

An SQL SELECT statement that defines the records and fields to return.

Default

Optional. The default selection.

Rows

Optional. Default = 0 (All rows returned).

HTML_Encoded

Optional. Default = .T. .T. = Format as HTML .F. = Do not format as HTML

The A5_HTML_LIST_ADO() function is used in Alpha Anywhere Application Server applications to query an ADO record source and return a list of choices for a list box or combo box control on an HTML Form.

Example

dim ado as P
ado.Type = "Access"
ado.MdbFileName = "C:\Northwind.mdb"
ado.sql = "select distinct city from customers order by city"
? a5_HTML_List_ADO(ADO)
= Aachen
Albuquerque
Anchorage
?hus
Barcelona
Barquisimeto

You can provide three optional arguments to the function. The first optional argument is the Default selected value. If no value is supplied, then when the SELECTED="SELECTED" keyword is not inserted into the list. The second optional argument specifies the maximum number of Rows to return. The default value for this argument is 0. If 0, then all rows in the query are returned. This could cause a problem if a very large number of rows is returned. The third optional argument is a logical flag that has a default value of .T.. This flag controls whether the data in the list should be HTML_Encoded. HTML encoding makes the function slower, so if you know that your data will not include any high order characters, you can speed up this function by setting the HTML_Encoded flag to .F.. This example show how the option list is selected with a default value and a maximum of 10 rows.

dim ado as P
ado.Type = "Access"
ado.MdbFileName = "C:\Northwind.mdb"
ado.sql = "select distinct city from customers order by city"
? a5_HTML_List_ADO(ADO,"Barcelona",10)
= Aachen
Albuquerque
Anchorage
?hus
Barcelona
Barquisimeto
Bergamo
Bern
Boise
Boston

ADO.Parameters

This example shows how you can use parameters in your SQL query string. Note the use of the ? placeholders for the parameters, and the ado.parameters array which contains the values of the replaceable parameters. In this case the query is searching for all cities that start with "L" or "N".

dim ado as P
dim ado.parameters2 as a
ado.Type = "Access"
ado.MdbFileName = "C:\Northwind.mdb"
ado.sql = "select distinct city from customers where city like ? or city like ? order by city"
ado.parameter_query = .t.
ado.parameters1 = "l%"
ado.parameters2 = "n%"
? a5_HTML_List_ADO(ADO)
= Lander
Leipzig
Lille
Lisboa
London
Lyon
Nantes

SQL Server

This example is similar to the one above, but instead of going against an Access .mdb file, the query is going against a table in a SQL Server database.

dim ado as P
dim ado.parameters2 as a
ado.connectionstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=selwyn1500"
ado.type = "connectionstring"
ado.sql = "select distinct city from customers where city like ? or city like ? order by city"
ado.parameter_query = .t.
ado.parameters1 = "l%"
ado.parameters2 = "n%"
?a5_HTML_List_ADO(ADO)
= Lander
Leipzig
Lille
Lisboa
London
Lyon
Nantes

See Also